package com.jboost.modules.open.service.impl;

import com.jboost.common.file.constant.FileHandleStatusEnum;
import com.jboost.modules.file.entity.JboostFile;
import com.jboost.modules.file.service.IJboostFileService;
import com.jboost.modules.open.vo.QiniuCallbackVo;
import com.jboost.modules.open.service.IOpenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 订单明细
 * @Author: jeecg-boot
 * @Date:   2022-10-22
 * @Version: V1.0
 */
@Service
public class OpenServiceImpl implements IOpenService {
    @Autowired
    private IJboostFileService fileService;

    @Override
    public void qiniuCallback(QiniuCallbackVo vo) {
        if (null == vo){
            return;
        }
        //文件处理结果
        String fileKey = vo.getInputKey();
        Integer code = vo.getCode();
        if (null == fileKey){
            return;
        }
        JboostFile file = fileService.getByFileKey(fileKey);
        if(null == file){
            return;
        }
        FileHandleStatusEnum statusEnum = FileHandleStatusEnum.getByValue(code);
        if (null!=statusEnum){
            file.setHandleStatus(statusEnum.getCode());
            fileService.updateById(file);
        }
    }
}
